import Vue from 'vue'
import VueRouter from 'vue-router'

// 路由懒加载
const Home = () => import('pages/Home/Home.vue')
const Category = () => import('pages/Category/Category.vue')
const Cart = () => import('pages/Cart/Cart.vue')
const Profile = () => import('pages/Profile/Profile.vue')
const Detail = () => import('pages/Detail/Detail.vue')

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home',
    meta: {
      showTabBar: true
    }
  },
  {
    path: '/home',
    component: Home,
    meta: {
      showTabBar: true
    }
  },
  {
    path: '/category',
    component: Category,
    meta: {
      showTabBar: true
    }
  },
  {
    path: '/cart',
    component: Cart,
    meta: {
      showTabBar: true
    }
  },
  {
    path: '/profile',
    component: Profile,
    meta: {
      showTabBar: true
    }
  },
  {
    path: '/detail/:id', // 动态传递 --如果只携带一个参数, 建议使用此种方式
    // path: '/detail', // query方式传递 --如果携带多个参数, 使用此种方式
    component: Detail,
    meta: {
      showTabBar: false
    }
  }
]

const router = new VueRouter({
  routes,
  mode: 'history'
})

export default router
